<html>
<head><meta charset="utf-8"><title>Masks, again, again · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.2C.20again.2C.20again.html">Masks, again, again</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="235080821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%2C%20again%2C%20again/near/235080821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.2C.20again.2C.20again.html#235080821">(Apr 18 2021 at 15:41)</a>:</h4>
<p>So an idea I've been toying with:</p>
<p>Architectures that support both full-width masks and bitmasks are rare.  Right now AVX-512 is the only one, and I doubt that will change any time soon.  I'm proposing a few changes from how I originally implemented masks</p>
<ul>
<li>Only support one mask format per architecture.  In the case of AVX-512, rely on the optimizer to convert full-width masks to bitmasks (I've seen that it can do it, at least in pretty trivial examples).  If you build with the AVX-512 target feature, I think it can default to bitmasks instead (this doesn't really help <code>std</code>, but we can do it as a proof of concept).</li>
<li>Provide two new functions on integers: converting <code>SimdI{N}</code> to integers by taking the sign bits, and the inverse operation for sign-extending integers to vectors.</li>
<li>Provide new functions on masks: converting <code>Mask{N}</code> to <code>SimdI{N}</code> and <code>Mask{N}</code> to integer, and the inverse operations.  We can indicate that some of these operations are free, depending on architecture (basically, free if they're the same size)</li>
</ul>



<a name="235081376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%2C%20again%2C%20again/near/235081376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.2C.20again.2C.20again.html#235081376">(Apr 18 2021 at 15:51)</a>:</h4>
<p>if it doesn't <em>block off</em> a future development we can definitely just call avx512 out of scope for the initial design</p>



<a name="235081670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%2C%20again%2C%20again/near/235081670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.2C.20again.2C.20again.html#235081670">(Apr 18 2021 at 15:56)</a>:</h4>
<p>I think my hope is also that we don't need to do anything special for AVX-512, we can mostly rely on the optimizer</p>



<a name="235081684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%2C%20again%2C%20again/near/235081684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.2C.20again.2C.20again.html#235081684">(Apr 18 2021 at 15:57)</a>:</h4>
<p>(pretty much what we're doing anyway)</p>



<a name="235089480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%2C%20again%2C%20again/near/235089480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.2C.20again.2C.20again.html#235089480">(Apr 18 2021 at 18:09)</a>:</h4>
<p>real fans will use avx512 intrinsics directly anyway (and be able to name five of their albums).</p>



<a name="235105012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%2C%20again%2C%20again/near/235105012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.2C.20again.2C.20again.html#235105012">(Apr 18 2021 at 21:55)</a>:</h4>
<p>this sounds like a good idea</p>



<a name="235537780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Masks%2C%20again%2C%20again/near/235537780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Masks.2C.20again.2C.20again.html#235537780">(Apr 21 2021 at 16:08)</a>:</h4>
<p>Sounds good to me, really. I have been thinking more about the calling convention problem that is holding us back, and I believe gating our repr on feature level is more practical. So as long as our external API for masks is relatively opaque to users until they call "deliberately get the mask" functions, I think we're mostly fine.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>